home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5021 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  645 b 

  1. Path: news.production.compuserve.com!news
  2. From: Steve Eckmann <71055.1153@CompuServe.COM>
  3. Newsgroups: comp.lang.c
  4. Subject: truncation function?
  5. Date: 11 Feb 1996 00:07:48 GMT
  6. Organization: CompuServe, Inc. (1-800-689-0736)
  7. Message-ID: <4fjc0k$nev$1@mhadg.production.compuserve.com>
  8.  
  9. I need a truncation function "float trunc(float in; int 
  10. precision)" that
  11. takes a float and a precision spec and returns the input float 
  12. truncated to
  13. "precision" decimal digits. Similarly for "round". This seems so 
  14. simple
  15. that I hesitate to ask, but on the other hand, my attempt (using 
  16. sprintf
  17. and sscanf) yields incorrect results sometimes. Thanks.
  18.  
  19. -Steve
  20.